package com.wx.app.ui.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.administrator.newemptyapplication.R;
import com.wx.app.mylib.app.BaseActivity;
import com.wx.app.mylib.view.popup.CommentPopup;
import com.wx.app.mylib.view.popup.MenuPopup;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class PopUpActivity extends BaseActivity {

    @BindView(R.id.btn_comment)
    Button btnComment;

    @BindView(R.id.btn_comment2)
    Button btnComment2;

    @BindView(R.id.btn_pop_menu)
    Button btnMenu;
    @BindView(R.id.btn_poptest)
    Button btnPopTest;

    private CommentPopup commentPopup;
    private MenuPopup menuPopup;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pop_up);
        ButterKnife.bind(mActivity);
        commentPopup = new CommentPopup(mActivity);
        menuPopup = new MenuPopup(mActivity);
        commentPopup.setOnCommentPopupClickListener(new CommentPopup.OnCommentPopupClickListener() {
            @Override
            public void onLikeClick(View v, TextView likeText) {
                if (v.getTag() == null) {
                    v.setTag(1);
                    likeText.setText("取消");
                } else {
                    switch ((int) v.getTag()) {
                        case 0:
                            v.setTag(1);
                            likeText.setText("取消");
                            break;
                        case 1:
                            v.setTag(0);
                            likeText.setText("赞  ");
                            break;
                    }
                }
            }

            @Override
            public void onCommentClick(View v) {
                showToast("评论");
            }
        });

        btnComment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                commentPopup.showPopupWindow(v);
            }
        });

        btnComment2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                commentPopup.showPopupWindow(v);
            }
        });
    }

//    @OnClick(R.id.btn_comment) void comm(){
//        commentPopup.showPopupWindow();
//
//    }


    @OnClick(R.id.btn_pop_menu)
    void menu() {
        menuPopup.showPopupWindow();

    }


}
